package cn.iborder.core;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import cn.iborder.utils.PubUtil;

public class ResMap{
	Map<Object, Object> resMap = new HashMap<>();

	public ResMap() {}

	public int size() {
		return resMap.size();
	}

	public boolean isEmpty() {
		return resMap.isEmpty();
	}

	public boolean containsKey(Object key) {
		return resMap.containsKey(key);
	}

	public boolean containsValue(Object value) {
		return resMap.containsValue(value);
	}

	public Object get(Object key) {
		return resMap.get(key);
	}

	public Object put(Object key, Object value) {
		return resMap.put(key, value);
	}

	public Object remove(Object key) {
		return resMap.remove(key);
	}

	public void putAll(Map<? extends Object, ? extends Object> m) {
		resMap.putAll(m);
	}

	public void clear() {
		resMap.clear();
	}

	public Set<Object> keySet() {
		return resMap.keySet();
	}

	public Collection<Object> values() {
		return resMap.values();
	}

	public Set<java.util.Map.Entry<Object, Object>> entrySet() {
		return resMap.entrySet();
	}
	
	public String getString(Object key) {
		return PubUtil.trim(resMap.get(key));
	}

	public int getInt(Object key) {
		return Integer.parseInt(PubUtil.trim(resMap.get(key)));
	}
	
	public Long getLong(Object key) {
		return Long.parseLong(PubUtil.trim(resMap.get(key)));
	}
	
	public Boolean getBoolean(Object key){
		String str = PubUtil.trim(resMap.get(key)).toLowerCase().trim();
		if ("true".equals(str)) {
			return true;
		} else if ("false".equals(str)) {
			return false;
		}else {
			//throw new RuntimeException("the value can not parse to Boolean : " + str);
			return false;
		}
	}
}
